Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close stream instead of dispose and fix unit test #3705

Merged
merged 2 commits into from
Dec 8, 2021
Merged

Conversation

PureWeen
Copy link
Member

@PureWeen PureWeen commented Dec 8, 2021

Description of Change

#3671 broke our Core.DeviceTests

  • Inside our DataFetcher code we were just disposing on Cleanup but this doesn't really do anything useful. It just disconnects the managed peer from the unmanaged peer. This code changes that to close the model if it's an InputStream. The only other type here that we use is a FontImageSourceModel that doesn't have any resources that need to be cleaned up
  • It looks like the use of a RequestBuilder causes the cached Bitmap to survive a bit longer so this adds some additional code that tries harder to collect and wait
  • The exception thrown from retrieving a no longer cached image is no longer wrapped inside of an ExecutionExceptionEngine exception
  • Added a RepeatAttribute for xUnit

PR Checklist

  • Targets the correct branch
  • Tests are passing (or failures are unrelated)
  • Targets a single property for a single control (or intertwined few properties)
  • Adds the property to the appropriate interface
  • Avoids any changes not essential to the handler property
  • Adds the mapping to the PropertyMapper in the handler
  • Adds the mapping method to the WinUI, Android, iOS, and Standard aspects of the handler
  • Implements the actual property updates (usually in extension methods in the Platform section of Core)
  • Tags ported renderer methods with [PortHandler]
  • Adds an example of the property to the sample project (MainPage)
  • Adds the property to the stub class
  • Implements basic property tests in DeviceTests

Does this PR touch anything that might affect accessibility?

  • Does this PR introduce a new control? (If yes, add an example using SemanticProperties to the SemanticsPage)
  • APIs that modify focusability?
  • APIs that modify any text property on a control?
  • Does this PR modify view nesting or view arrangement in anyway?
  • Is there the smallest possibility that your PR will change accessibility?
  • I'm not sure, please help me

If any of the above checkboxes apply to your PR, then the PR will need to provide testing to demonstrate that accessibility still works.

Comment on lines +22 to +29
protected async Task WaitForGC()
{
GC.Collect();
GC.WaitForPendingFinalizers();
await Task.Delay(10);
GC.Collect();
GC.WaitForPendingFinalizers();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing to mention is the Mono runtime team had us use this class:

https://github.com/xamarin/java.interop/blob/bc5bcf4f0ef07aab898f2643d2a25f66512d98ed/tests/Java.Interop-Tests/Java.Interop/FinalizerHelpers.cs

It fills the stack 128 methods deep, to make tests able to wait on the GC more reliably.

But I think you could probably wait and see if these tests fail randomly down the road.

@PureWeen PureWeen merged commit b1f0687 into main Dec 8, 2021
@PureWeen PureWeen deleted the fix_fetch_dispose branch December 8, 2021 21:31
@samhouts samhouts added area-image Image loading, sources, caching area-controls-image Image control platform/android 🤖 labels Jul 10, 2023
@ghost ghost added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Jul 10, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Dec 24, 2023
@Eilon Eilon removed legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor area-image Image loading, sources, caching labels May 10, 2024
@samhouts samhouts added the fixed-in-6.0.200-preview.12 Look for this fix in 6.0.200-preview.12! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-image Image control fixed-in-6.0.200-preview.12 Look for this fix in 6.0.200-preview.12! platform/android 🤖
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants